<!DOCTYPE html>
<html class="x-admin-sm">
  <head>
    <meta charset="UTF-8">
    <title></title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,height=device-height,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <link rel="stylesheet" href="__ADMIN__/css/font.css">
    <link rel="stylesheet" href="__ADMIN__/css/xadmin.css">
    <script type="text/javascript" src="__ADMIN__/js/jquery.min.js"></script>
    <script type="text/javascript" src="__ADMIN__/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="__ADMIN__/js/xadmin.js"></script>
    <script type="text/javascript" src="__ADMIN__/js/cookie.js"></script>
    <style>
        .layui-form-item .layui-form-label{
            width: 120px;
        }
        .layui-form-item .layui-textarea{
            width: 190px;
        }
    </style>
  </head>
  
  <body>
    <div class="x-body">
        <form class="layui-form">

          <table class="layui-table">
          <colgroup>
            <col width="200">
            <col width="600">
          </colgroup>
          <tbody>
            <tr>
              <td>申请人</td>
              <td>{:idToAdminname($info.admin_id)}</td>
            </tr>
            <tr>
              <td>申请时间</td>
              <td>{$info.add_time|date="Y-m-d H:i",###}</td>
            </tr>
            <tr>
              <td>活动名称</td>
              <td>{:getClientInfoById($info.client_id,'activity')} {if $info.live_id}{$info.activity_name} - {$info.live_id}{/if}</td>
            </tr>
            <tr>
              <td>礼品</td>
              <td>{$info.goods_name}</td>
            </tr>      
            <tr>
              <td>申请数量</td>
              <td>{$info.count}</td>
            </tr>
            <tr><td></td><td></td></tr>
            <tr>
              <td>收货人</td>
              <td><input type="text" value="{$info.consignee}" id="consignee" name="consignee" autocomplete="off" class="layui-input"></td>
            </tr>
            <tr>
              <td>联系方式</td>
              <td><input type="text" value="{$info.phone}" id="phone" name="phone" autocomplete="off" class="layui-input"></td>
            </tr>
            <tr>
              <td>收货地址</td>
              <td>{$info.address}</td>
            </tr>
            <tr><td></td><td></td></tr>
            <tr>
              <td>状态</td>
              <td>{switch name="$info.status"}{case value="-1"}拒绝发货{/case}{case value="0"}待发货{/case}{case value="1"}已发货{/case}{/switch}</td>
            </tr>
            {if condition="$info.send_admin_id"}
            <tr>
              <td>处理人</td>
              <td>{:idToAdminname($info.send_admin_id)}</td>
            </tr>
            <tr>
              <td>处理时间</td>
              <td>{$info.send_time|date="Y-m-d H:i",###}</td>
            </tr>
            {if condition="session('uid','','admin') eq $info.send_admin_id || session('group_id','','admin') eq 1"}
            <tr>
              <td>快递单号</td>
              <td>              
                  <input type="text" value="{$info.express_num}" id="express_num" name="express_num" autocomplete="off" class="layui-input">
              </td>
            </tr>
            <tr>
              <td>备注</td>
              <td>              
                  <input type="text" value="{$info.send_note}" id="send_note" name="send_note" autocomplete="off" class="layui-input">
              </td>
            </tr>
            <tr>
              <td></td>
              <td>              
                  <button type="button" class="layui-btn layui-btn-normal" lay-submit lay-filter="edit" >
                      修改
                  </button>
              </td>
            </tr>
            {else /}
            {if condition="$info.express_num"}
            <tr>
              <td>快递单号</td>
              <td>{$info.express_num}</td>
            </tr>
            {/if}
            {if condition="$info.send_note"}
            <tr>
              <td>备注</td>
              <td>{$info.send_note}</td>
            </tr>
            {/if}
            {/if}
            {else /}
            <tr>
              <td>快递单号</td>
              <td>              
                  <input type="text" value="" id="express_num" name="express_num" autocomplete="off" class="layui-input">
              </td>
            </tr>
            <tr>
              <td>备注</td>
              <td>              
                  <input type="text" value="" id="send_note" name="send_note" autocomplete="off" class="layui-input">
              </td>
            </tr>
            <tr>
              <td></td>
              <td>              
                  <button type="button" class="layui-btn layui-btn-normal" lay-submit lay-filter="submit" lay-submit="submit" id="1">
                      发货
                  </button>
                  <button type="button" class="layui-btn layui-btn-normal" lay-submit lay-filter="submit" lay-submit="submit" id="-1">
                      拒绝
                  </button>
              </td>
            </tr>
            {/if}

          </tbody>
          </table>
          {if condition="!$info.reply_admin_id && 1==2"}
          <div class="layui-form-item">
              <label for="L_repass" class="layui-form-label">
              </label>
              <button type="button" class="layui-btn layui-btn-normal" lay-filter="submit" id="1" lay-submit="">
                  发货
              </button>
              <button type="button" class="layui-btn layui-btn-danger" lay-filter="submit" id="-1" lay-submit="">
                  拒绝
              </button>
          </div>
          {/if}
      </form>
    </div>
    <script>
        layui.use(['form','layer','laydate','upload'], function(){
          $ = layui.jquery;
          var form = layui.form
          ,layer = layui.layer
          ,laydate = layui.laydate
          ,upload = layui.upload;
          
          form.on('submit(submit)', function(data){
            if(!this.id)
                return;
            else if(this.id == 1 && !data.field.express_num)
            {
                layer.alert('请输入单号。');
                return;
            }
            else if(this.id == -1 && !data.field.send_note)
            {
                layer.alert('请输入拒绝备注。');
                return;
            }
            
            data.field.status = this.id;
            $.ajax({
                type:'POST',
                dataType:'json',
                data:{data:data.field},
                url:"{:url('goodsOrders/ordersSend')}/id/{$info.id}",
                success:function(obj){
                  layer.alert(obj.msg, {icon: obj.icon},function(){
                    // 获得frame索引
                    var index = parent.layer.getFrameIndex(window.name);
                    //关闭当前frame
                    parent.layer.close(index);
                    // 可以对父窗口进行刷新 
                    x_admin_father_reload();
                  });
                }
            });
            return false;
          });
          form.on('submit(edit)', function(data){ 
            $.ajax({
                type:'POST',
                dataType:'json',
                data:{data:data.field},
                url:"{:url('goodsOrders/ordersEdit')}/id/{$info.id}",
                success:function(obj){
                  layer.alert(obj.msg, {icon: obj.icon},function(){
                    // 获得frame索引
                    var index = parent.layer.getFrameIndex(window.name);
                    //关闭当前frame
                    parent.layer.close(index);
                    // 可以对父窗口进行刷新 
                    x_admin_father_reload();
                  });
                }
            });
            return false;
          });
        });
    </script>
  </body>

</html>